package com.donger.mq.producer;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@AllArgsConstructor
@Slf4j
public class Sender {

    private final RabbitTemplate rabbitTemplate;

    public void send(String str) {
        String context = "hello " + new Date();
        if (StrUtil.isNotEmpty(str)) {
            context = str;
        }
        System.out.println("Sender : " + context);
        log.info("Sender :  -> {}", context);
        rabbitTemplate.convertAndSend("hello", context);
    }


}
